/*
 * @Author: 15663569761 1697354625@qq.com
 * @Date: 2023-05-26 20:14:12
 * @LastEditors: 15663569761 1697354625@qq.com
 * @LastEditTime: 2023-05-26 20:22:08
 * @FilePath: /lesson43/tcpServer/tcpServer.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include"tcpServer.hpp"
#include"daemon.hpp"
#include<memory>
using namespace server;
using namespace std;

static void Usage(string proc)
{
    cout << "Usage:\n\t" << proc << " local_port\n\n";
}

// 使用方式：./tcpServer  local_port(和udpserver一模一样)
int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }

    uint16_t port = atoi(argv[1]);
    unique_ptr<TcpServer> tsvr(new TcpServer(port));
    tsvr->initServer();
    daemonSelf();
    tsvr->start();

   

    // while(true)
    // {
    //     sleep(1);//服务器的核心逻辑
    // }

    return 0;
}